package ar.com.ironsoft.javaopenauth.web;

import java.io.IOException;

import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import ar.com.ironsoft.javaopenauth.oauth.OAuthService;

/**
 * Simple abstract class to extend HttpServlet for adding a OAuthService
 * property and make visible the doGet and doPost methods.
 * 
 * @author Tomas de Priede
 * @version 0.1.2, 05/02/2011
 * @since 0.1.2-SNAPSHOT
 */
@SuppressWarnings("serial")
public abstract class HttpVisibleServlet extends HttpServlet {

	private OAuthService service;

	/**
	 * Builds a HttpVisibleServlet with one OAuthService
	 * @param service the service to contain
	 * @author Tomas de Priede
	 * @version 0.1.2, 05/02/2011
	 * @since 0.1.2-SNAPSHOT
	 */
	public HttpVisibleServlet(OAuthService service) {
		super();
		this.service = service;
	}

	/**
	 * Makes visible the doGet method
	 * @param request The http request
	 * @param response The http response
	 * @author Tomas de Priede
	 * @version 0.1.2, 05/02/2011
	 * @since 0.1.2-SNAPSHOT
	 */
	public abstract void doGet(HttpServletRequest request,
			HttpServletResponse response) throws IOException;

	/**
	 * Makes visible the doPost method
	 * @param request The http request
	 * @param response The http response
	 * @author Tomas de Priede
	 * @version 0.1.2, 05/02/2011
	 * @since 0.1.2-SNAPSHOT
	 */
	public abstract void doPost(HttpServletRequest request,
			HttpServletResponse response) throws IOException;

	/**
	 * Returns the oauth service
	 * @return the oauth service
	 * @author Tomas de Priede
	 * @version 0.1.2, 05/02/2011
	 * @since 0.1.2-SNAPSHOT
	 */
	public OAuthService getService() {
		return service;
	}

	/**
	 * Sets the oauth service
	 * @param service the service to set
	 * @author Tomas de Priede
	 * @version 0.1.2, 05/02/2011
	 * @since 0.1.2-SNAPSHOT
	 */
	public void setService(OAuthService service) {
		this.service = service;
	}

}
